package br.ufpb.di.ppgi.apresentacao.interceptors;

import br.com.caelum.vraptor.InterceptionException;
import br.com.caelum.vraptor.core.InterceptorStack;
import br.com.caelum.vraptor.interceptor.Interceptor;
import br.com.caelum.vraptor.ioc.Component;
import br.com.caelum.vraptor.ioc.RequestScoped;
import br.com.caelum.vraptor.resource.ResourceMethod;
import br.ufpb.di.ppgi.util.vraptor.ContainerRequestScoped;

@Component
@RequestScoped
public class FirstInterceptor implements Interceptor {
	
	private final ContainerRequestScoped crs;

	public FirstInterceptor(ContainerRequestScoped crs) {
		this.crs = crs;
	}
	
	@Override
	public boolean accepts(ResourceMethod resource) {
		return true;
	}
	
	@Override
	public void intercept(InterceptorStack stack, ResourceMethod method, 
			Object resourceInstance) throws InterceptionException {

			crs.toString();
			stack.next(method, resourceInstance);
	}
}
